/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.employee.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.sys.entity.Store;
import com.google.common.collect.Lists;

/**
 * 员工结算单Entity
 * @author liujiang
 * @version 2013-11-21
 */
@Entity
@Table(name = "store_employee_accounting")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreEmployeeAccounting extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	private Long id; 		// 编号
	private Store store; 	// 名称
	private Date accounting_time;	//结算时间
	private float total_salary;	// 合计薪资
	private List<StoreEmployeeAccountingDetail> detailList = Lists.newArrayList();
	
	public StoreEmployeeAccounting() {
	}

	public StoreEmployeeAccounting(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	public Date getAccounting_time() {
		return accounting_time;
	}

	public void setAccounting_time(Date accounting_time) {
		this.accounting_time = accounting_time;
	}

	public float getTotal_salary() {
		return total_salary;
	}

	public void setTotal_salary(float total_salary) {
		this.total_salary = total_salary;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="storeEmployeeAccounting")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<StoreEmployeeAccountingDetail> getDetailList() {
		return detailList;
	}

	public void setDetailList(List<StoreEmployeeAccountingDetail> detailList) {
		this.detailList = detailList;
	}
}


